import java.util.ArrayList;
import java.util.List;

/**
 * Created by zhangjinrui on 17/6/27.
 */

public class Solution386 {

    public static void main(String args[]){
        Solution386 s = new Solution386();
        System.out.println(s.lexicalOrder(100));
    }

    List<Integer> ret;
    public List<Integer> lexicalOrder(int n) {
        ret = new ArrayList<>();
        for(int i = 1; i <= 9 ; i ++){
            dfs(i, n);
        }
        return ret;
    }

    public void dfs(int v, int maxv){
        if(v > maxv){
            return;
        }
        ret.add(v);
        for(int i = 0 ; i <= 9 ; i ++){
            dfs(v * 10 + i, maxv);
        }
    }

}
